package de.lgohlke.helper;

import java.util.Date;

/**
 * easily comparing Dates
 *
 * @author lars
 * @version $Id: $
 */
public class DateComparer
{
	public static class COMPARED_TO_DEFINITION
	{

		private final int	compareValue;
		private final Date	date;

		public COMPARED_TO_DEFINITION(Date d1, int compareValue)
		{
			this.date = d1;
			this.compareValue = compareValue;
		}

		public boolean comparedTo(Date d2)
		{
			int c = date.compareTo(d2);
			return compareValue == c;
		}
	}

	/**
	 * <p>isAtSameTime.</p>
	 *
	 * @param d1 a {@link java.util.Date} object.
	 * @return a {@link de.lgohlke.helper.DateComparer.COMPARED_TO_DEFINITION} object.
	 */
	public COMPARED_TO_DEFINITION isAtSameTime(Date d1)
	{
		return new COMPARED_TO_DEFINITION(d1, 0);
	}

	/**
	 * <p>isBefore.</p>
	 *
	 * @param d1 a {@link java.util.Date} object.
	 * @return a {@link de.lgohlke.helper.DateComparer.COMPARED_TO_DEFINITION} object.
	 */
	public COMPARED_TO_DEFINITION isBefore(Date d1)
	{
		return new COMPARED_TO_DEFINITION(d1, -1);
	}

	/**
	 * <p>isLater.</p>
	 *
	 * @param d1 a {@link java.util.Date} object.
	 * @return a {@link de.lgohlke.helper.DateComparer.COMPARED_TO_DEFINITION} object.
	 */
	public COMPARED_TO_DEFINITION isLater(Date d1)
	{
		return new COMPARED_TO_DEFINITION(d1, 1);
	}
}
